import { createApp } from 'vue'
import App from './App.vue'
import '@/theme/index.less'
import '@/theme/var.css'
import 'virtual:svg-icons-register'
// Router
import { setupRouter } from '@/router'
// Antd
import { setupAntd } from '@/lib/ant-design-vue'
// Pinia
import { setupStore } from '@/store'
// NProgress
import { setupNProgress } from '@/lib/nprogress'
// I18n
import { setupI18n } from '@/i18n'
import close from '@/components/framework/close/index.vue'
import CopyText from '@/components/support/copy-text/index.vue'

window.addEventListener('vite:preloadError', (event) => {
  event.preventDefault()
  window.location.reload()
})

async function setupAll() {
  const app = createApp(App)

  setupStore(app)

  await setupRouter(app)

  setupAntd(app)

  setupNProgress()

  setupI18n(app)
  app.component('Close', close)
  app.component('CopyText', CopyText)
  app.mount('#app')
}
setupAll().then()
